-- 衍生技 歧路寻道
local qiluxundao = fk.CreateSkill {
    name = "mcdh_qiluxundao",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

qiluxundao:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and player.phase == Player.Start and player:getMark("mcdh_ammo") >= 2
    end,
    on_cost = function(self,event,target,player,data)
        return player.room:askForSkillInvoke(player, self.name, nil, "#qiluxundao-invoke::" )
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        lib.LoseAmmo(player,player,2,self.name)
        player:drawCards(3, self.name)
        if player.chained and room:askForSkillInvoke(player, self.name, nil, "#mcdh_qiluxundao-1")then
            player:setChainState(false)
        elseif not player.chained and room:askForSkillInvoke(player, self.name, nil, "#mcdh_qiluxundao-2") then
            player:setChainState(true)
        end
    end,
})

Fk:loadTranslationTable {
    ["mcdh_qiluxundao"] = "寻心",
    [":mcdh_qiluxundao"] = "『歧路寻道』<br>装填技（2），准备阶段，你可以摸三张牌，然后你可以重置或横置。",
    ["#qiluxundao-invoke"] = "歧路寻道：摸三张牌，然后你可以重置或横置。",
    ["#mcdh_qiluxundao-1"] = "歧路寻道：重置",
    ["#mcdh_qiluxundao-2"] = "歧路寻道：横置",
}

return qiluxundao